package com.example.testapp.utils;

import com.example.testapp.R;

import java.util.HashMap;
import java.util.Map;

public class GetCategoryIcon {
    // 哈希表：分类类型 -> 图标资源 ID
    private static final Map<String, Integer> categoryIconMap = new HashMap<>();

    static {
        // 餐饮类
        categoryIconMap.put("餐饮", R.drawable.vector_drawable_ic_food);
        categoryIconMap.put("美食", R.drawable.vector_drawable_ic_food);
        categoryIconMap.put("午餐", R.drawable.vector_drawable_ic_food);
        categoryIconMap.put("晚餐", R.drawable.vector_drawable_ic_food);
        categoryIconMap.put("早餐", R.drawable.vector_drawable_ic_food);
        categoryIconMap.put("零食", R.drawable.vector_drawable_ic_food);
        categoryIconMap.put("外卖", R.drawable.vector_drawable_ic_food);

        // 购物类
        categoryIconMap.put("购物", R.drawable.vector_drawable_ic_shopping);
        categoryIconMap.put("衣服", R.drawable.vector_drawable_ic_shopping);
        categoryIconMap.put("鞋子", R.drawable.vector_drawable_ic_shopping);
        categoryIconMap.put("包包", R.drawable.vector_drawable_ic_shopping);
        categoryIconMap.put("首饰", R.drawable.vector_drawable_ic_shopping);
        categoryIconMap.put("数码产品", R.drawable.vector_drawable_ic_shopping);
        categoryIconMap.put("家居用品", R.drawable.vector_drawable_ic_shopping);
        categoryIconMap.put("美妆", R.drawable.vector_drawable_ic_shopping);

        // 交通类
        categoryIconMap.put("交通", R.drawable.vector_drawable_ic_transport);
        categoryIconMap.put("公交", R.drawable.vector_drawable_ic_transport);
        categoryIconMap.put("地铁", R.drawable.vector_drawable_ic_transport);
        categoryIconMap.put("打车", R.drawable.vector_drawable_ic_transport);
        categoryIconMap.put("共享单车", R.drawable.vector_drawable_ic_transport);
        categoryIconMap.put("加油", R.drawable.vector_drawable_ic_transport);
        categoryIconMap.put("停车", R.drawable.vector_drawable_ic_transport);

        // 娱乐类
        categoryIconMap.put("娱乐", R.drawable.vector_drawable_ic_entertainment);
        categoryIconMap.put("电影", R.drawable.vector_drawable_ic_entertainment);
        categoryIconMap.put("音乐", R.drawable.vector_drawable_ic_entertainment);
        categoryIconMap.put("游戏", R.drawable.vector_drawable_ic_entertainment);
        categoryIconMap.put("旅游", R.drawable.vector_drawable_ic_entertainment);
        categoryIconMap.put("运动", R.drawable.vector_drawable_ic_entertainment);
        categoryIconMap.put("健身", R.drawable.vector_drawable_ic_entertainment);
        categoryIconMap.put("聚会", R.drawable.vector_drawable_ic_entertainment);
        categoryIconMap.put("酒吧", R.drawable.vector_drawable_ic_entertainment);
        categoryIconMap.put("KTV", R.drawable.vector_drawable_ic_entertainment);

        // 住房类
        categoryIconMap.put("住房", R.drawable.vector_drawable_ic_housing);
        categoryIconMap.put("房租", R.drawable.vector_drawable_ic_housing);
        categoryIconMap.put("房贷", R.drawable.vector_drawable_ic_housing);
        categoryIconMap.put("水电费", R.drawable.vector_drawable_ic_housing);
        categoryIconMap.put("物业管理", R.drawable.vector_drawable_ic_housing);
        categoryIconMap.put("房屋维修", R.drawable.vector_drawable_ic_housing);

        // 医疗类
        categoryIconMap.put("医疗", R.drawable.vector_drawable_ic_medical);
        categoryIconMap.put("医疗健康", R.drawable.vector_drawable_ic_medical);
        categoryIconMap.put("健康", R.drawable.vector_drawable_ic_medical);
        categoryIconMap.put("医药", R.drawable.vector_drawable_ic_medical);
        categoryIconMap.put("医院", R.drawable.vector_drawable_ic_medical);
        categoryIconMap.put("诊所", R.drawable.vector_drawable_ic_medical);
        categoryIconMap.put("体检", R.drawable.vector_drawable_ic_medical);
        categoryIconMap.put("药品", R.drawable.vector_drawable_ic_medical);

        // 收入类
        categoryIconMap.put("工资", R.drawable.vector_drawable_ic_salary);
        categoryIconMap.put("薪水", R.drawable.vector_drawable_ic_salary);
        categoryIconMap.put("奖金", R.drawable.vector_drawable_ic_salary);
        categoryIconMap.put("分红", R.drawable.vector_drawable_ic_salary);
        categoryIconMap.put("稿费", R.drawable.vector_drawable_ic_salary);

        // 投资类
        categoryIconMap.put("投资", R.drawable.vector_drawable_ic_investment);
        categoryIconMap.put("理财", R.drawable.vector_drawable_ic_investment);
        categoryIconMap.put("股票", R.drawable.vector_drawable_ic_investment);
        categoryIconMap.put("基金", R.drawable.vector_drawable_ic_investment);
        categoryIconMap.put("债券", R.drawable.vector_drawable_ic_investment);
        categoryIconMap.put("保险", R.drawable.vector_drawable_ic_investment);

        // 其它类
        categoryIconMap.put("其它", R.drawable.vector_drawable_ic_other);
        categoryIconMap.put("其他", R.drawable.vector_drawable_ic_other);
        categoryIconMap.put("杂项", R.drawable.vector_drawable_ic_other);
        categoryIconMap.put("未分类", R.drawable.vector_drawable_ic_other);
    }

    /**
     * 根据分类类型获取图标资源 ID
     *
     * @param category 分类类型
     * @return 图标资源 ID，如果分类类型不存在则返回“其它”类型的资源 ID
     */
    public static int getIconId(String category) {
        // 如果分类类型为空或哈希表中不存在该分类类型，则返回“其它”类型的资源 ID
        return categoryIconMap.getOrDefault(category, categoryIconMap.get("其它"));
    }
}